package com.mf.common.exception;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CustomException extends RuntimeException {
	private Logger logger;

	private Exception e;
	private String customMsg;

	/*
	 * METHOD
	 */
	// public GenericException(String customMsg) {
	//
	// this.customMsg = customMsg;
	// // ErrorKonusu konu = new ErrorKonusu();
	// //
	// // konu.gozlemciEkle(new LanguageBean());
	// //
	// // konu.fiyatDeğiştir(true);
	//
	// // this.logger = LoggerFactory.getLogger(cls);
	// // logger.error(customMsg);
	// // FacesUtils.addMessage(FacesMessage.SEVERITY_ERROR, "ERROR_SYSTEM");
	// }

	public CustomException(Exception e, Class cls) {
		this.e = e;
		this.logger = LoggerFactory.getLogger(cls);

		StringWriter stringWriter = new StringWriter();
		PrintWriter printWriter = new PrintWriter(stringWriter);
		e.printStackTrace(printWriter);

		logger.error(stringWriter.toString());
	}

	/*
	 * GETTER- SETTER
	 */
	public String getCustomMsg() {
		return customMsg;
	}

	public void setCustomMsg(String customMsg) {
		this.customMsg = customMsg;
	}

}